package com.microservice.postservice.controller;


import com.microservice.commonutils.R;
import com.microservice.postservice.entity.PostImage;
import com.microservice.postservice.service.PostImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author leesin
 * @since 2022-05-14
 */
@RestController
@RequestMapping("/postservice/postimage")
public class PostImageController {

    @Autowired
    private PostImageService postImageService;

    @PostMapping("addImage")
    public R addImage(@RequestBody PostImage postImage){
        boolean addImage =postImageService.addImage(postImage);
        if (addImage){
            return R.ok().data("postImage",postImage);
        }else {
            return R.error();
        }
    }

    /**
     * 测试用
     * @param postImage
     * @return
     */
    @PostMapping("insertImage")
    public R insert(@RequestBody PostImage postImage){
        boolean save = postImageService.save(postImage);
        if (save){
            return R.ok().data("sava",postImage);
        }else {
            return R.error();
        }
    }

}

